package cn.JHai.rbac.query;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Setter
@Getter
public class PageResult {
    //当前页面
    private Long currentPage=1l;
    //页面大小
//    ############## lord_can ##############
    private Long pageSize=3l;
//    ############## lord_can ##############
    // 页面的内容
    private List list;
    //总条数
    private Long count;
    //上页
    private Long prePage;
    //下页
    private Long nextPage;
    //总页数
    private Long totalPage;

    //字典id
    private Long parent_id;

//    ############## lord_can ##############
    //当前查询的关键词
    private String currentKeyword;

    public String getCurrentKeyword() {
        return currentKeyword;
    }

    public void setCurrentKeyword(String currentKeyword) {
        this.currentKeyword = currentKeyword;
    }
    //    ############## lord_can ##############

    public PageResult(long currentPage, long pageSize, List list, Long count) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.list = list;
        this.count = count;
        /*this.prePage = prePage;
        this.nextPage = nextPage;
        this.totalPage = totalPage;*/
        if(currentPage==1l){
            this.prePage = 1l;
        }else{
            this.prePage = currentPage-1;
        }

        if(this.count%this.pageSize==0){
            this.totalPage = this.count/this.pageSize;
        }else {
            this.totalPage = this.count/this.pageSize+1;
        }

        if(currentPage==totalPage){
            this.nextPage = totalPage;
        }else{
            this.nextPage = currentPage+1;
        }

    }
}
